/*
 *  rigidbody3d4p.h
 *  EPPI-0.0
 *
 *  Created by Juan Carlos Garcia Orden on 21/03/2011
 *	Modified by Roberto Ortega 01/04/2011
 */
 
#ifndef _rigidbody3d4p_h_
#define _rigidbody3d4p_h_

#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iterator>
#include "mecsystem.h"
#include "body.h"
#include "point.h"
#include "COMPONENTS/rb3d4p.h"

class MecSystem;

using namespace std;

class RigidBody3d4p : public Body
{
public:
/*	Data members from the base class Body
	string name;
	int dim;
	MecSystem* parentSystem;
	vector<Component*> vComponents;
	vector<Component*> vLoads;
	vector<string> vPointNamesSurface;
	vector<Point*> vPPointSurface;
	map<string,int,less<string> > pNamePNumber;
	string outGraphFilex;
	vector<vector<double> > vLocalPoints;	// Local points, for joints and contact
*/
	// Local Data Members *****************************************************/
		
	// Local Points and Local Elements
//	int nLocalPoints;
//	int nLocalElements;
//	vector<vector<int> > vLocalElements;
	vector<vector<double> > R;	// Rotation matrix
	vector<double> cm;			// Coordinates of the center of mass


public:
	RigidBody3d4p(){}
	RigidBody3d4p(ifstream &, string, MecSystem*);
	~RigidBody3d4p(){}
	
	/** Virtual functions from base */
	void setPTPointsComp();		/** Set pointers to points in each component */
	void setPTPointsLoad();		/** Set pointers to points in each load */
	void setPPointSurface();
	void setMatAtComp();
	void getBoundary(vector<vector<string> >&);
	void writeMSH(ofstream&);
	void writeVTU(ofstream&, bool&, bool&, bool&);		
	void writeOOGL(ofstream&);
	void writeFileTemp(const double&, ofstream &);
	void setIniPosBody(vector<double>&);
	
	/** Local functions */
//	void updateLocalPoints(void);
	void calcR();
	
	friend void printSTLMatrix(const vector< vector<double> >& m);
	friend void rigidTransOver(vector<double>&, vector<double>&, vector<vector<double> >&);	// Rigid transformation
};

#endif